package com.ziyueyuwen.xiniao.controller.curve;


import com.alibaba.fastjson.JSON;
import com.ziyueyuwen.xiniao.bean.area.AreaMapValue;
import com.ziyueyuwen.xiniao.bean.area.ZyArea;

import com.ziyueyuwen.xiniao.bean.subscription.ZySubscriptionMsgDO;
import com.ziyueyuwen.xiniao.service.baseservice.area.AreaBaseService;
import com.ziyueyuwen.xiniao.util.StreamUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author wancheng  on 2019/3/8.
 */
@Controller
@RequestMapping("/statistics")
public class MapController {

    @Autowired
    AreaBaseService areaBaseService;

    @RequestMapping(value = "/map", method = RequestMethod.GET)
    public String curve(Model model) {
        List<ZyArea> areas = areaBaseService.getAreaOfStudent();
        List<AreaMapValue> areaMapValues = areas.stream().map(a -> new AreaMapValue(a.getName(), new String[]{a.getLog(), a.getLat()}, 0)).collect(Collectors.toList());
        model.addAttribute("cityData", JSON.toJSON(areaMapValues));
        return "/statistics/map";
    }

    @RequestMapping(value = "/map/gaode", method = RequestMethod.GET)
    public String curveGaoDe(Model model) {
        List<ZyArea> areas = areaBaseService.getAreaOfStudent();
        List<AreaMapValue> areaMapValues = areas.stream().map(a -> new AreaMapValue(a.getName(), new String[]{a.getLog(), a.getLat()}, 0)).collect(Collectors.toList());
        model.addAttribute("cityData", JSON.toJSON(areaMapValues));
        return "/statistics/gaode_map";
    }
}
